package org.come.control;

import com.tool.role.RoleData;
import org.come.Frame.XYJframe;
import org.come.Frame.XYXYDJframe;
import org.come.action.FromServerAction;
import org.come.entity.RoleSummoning;
import org.come.until.FormsManagement;
import org.come.until.UserMessUntil;
import org.skill.frame.SkillMainFrame;
import org.skill.panel.SkillMainPanel;

import com.tool.role.BaseMeridians;
import com.tool.role.RoleProperty;

/**
 * @author HGC<br>
 * @time 2020年5月13日 下午5:06:14<br>
 * @class 类名:RolechangeControl 人物经脉修炼返回数据<br>
 */
public class RolechangeControl implements FromServerAction{

    @Override
    public void controlMessFromServer(String mes, String type) {
        if ("XY".equals(mes.split("-")[0])){
            if(!"null".equals(mes.split("-")[1])){
                int dianshu= Integer.parseInt(mes.split("-")[1].split("#")[mes.split("-")[1].split("#").length-1]);
                XYXYDJframe.getXYXYDJfeame().getXyxydJpanel().CS(dianshu,mes.split("-")[1]);
                XYJframe.getXYJframe().getXyJpanel().CS(dianshu,mes.split("-")[1]);
            }else {
                XYXYDJframe.getXYXYDJfeame().getXyxydJpanel().CS(0,null);
                XYJframe.getXYJframe().getXyJpanel().CS(0,null);
            }

            RoleSummoning chosePetMes = UserMessUntil.getChosePetMes();
            if(chosePetMes==null){
                return;
            }
            chosePetMes.setXy(mes);

            FormsManagement.showForm(125);
            return;
        }
        if ("XY1".equals(mes.split("-")[0])){
            if ( XYJframe.getXYJframe().getXyJpanel().isVisible()) {
                FormsManagement.HideForm(124);
            }
            if(!"null".equals(mes.split("-")[1])){
                int dianshu= Integer.parseInt(mes.split("-")[1].split("#")[mes.split("-")[1].split("#").length-1]);
                // XYXYDJframe.getXYXYDJfeame().getXyxydJpanel().CS(dianshu);
                XYJframe.getXYJframe().getXyJpanel().CS(dianshu,mes.split("-")[1]);
            }else {
                XYXYDJframe.getXYXYDJfeame().getXyxydJpanel().CS(0,null);
                XYJframe.getXYJframe().getXyJpanel().CS(0,null);
            }

            RoleSummoning chosePetMes = UserMessUntil.getChosePetMes();
            if(chosePetMes==null){
                return;
            }
            chosePetMes.setXy(mes);

            FormsManagement.showForm(124);
            return;
        }
        //修改LoginResult 中的数据
        BaseMeridians upMeridians = RoleProperty.getRoleProperty().upMeridians(mes.replaceAll("\"", ""));
        RoleProperty.ResetEw();
//        (如果经脉界面打开的话)
//        刷新经脉界面
        if(upMeridians !=null){
            RoleData.getRoleData().getLoginResult().setMeridians(upMeridians);
            if(FormsManagement.getInternalForm2(82)!=null){
                if(FormsManagement.getframe(82).isVisible()){
                    SkillMainPanel skillMainPanel = SkillMainFrame.getSkillMainFrame().getSkillMainPanel();
                    if(skillMainPanel.getTypeBtn() == 2){
                        skillMainPanel.getMeridiansMainJpanel().serverRefreshView(upMeridians);
                    }
                }
            }
        }
    }
}
